package org.cliff.message.platform.core.util;

import org.cliff.message.platform.core.domain.ProcessStatusConstants;
import org.cliff.message.platform.core.domain.ReceivedMessage;

/**
 * 消息组件平台ThreadLocal
 * @author 刘文
 * @date 2023/10/16
 */
public class MessagePlatformThreadLocals {

    /**
     * 接收到消息ThreadLocal
     */
    public static final ThreadLocal<ReceivedMessage> RECEIVED_MESSAGE = new InheritableThreadLocal<>();

    /**
     * 消息处理ThreadLocal 值见{@link ProcessStatusConstants}
     */
    public static final ThreadLocal<String> PROCESS_STATUS = new ThreadLocal<>();

    /**
     * 数据状态
     */
    public static final ThreadLocal<String> DATA_STATUS = new ThreadLocal<>();

    public static final ThreadLocal<Long> REQUEST_PROCESS_START_TIME = new ThreadLocal<>();

    public static void clean() {
        RECEIVED_MESSAGE.remove();
        PROCESS_STATUS.remove();
        DATA_STATUS.remove();
        REQUEST_PROCESS_START_TIME.remove();
    }
}
